<template>
  <div>
    <!-- 卡片 -->
    <van-card
      v-for="item in classifyList"
      :key="item.id"
      :price="item.price.toFixed(2)"
      desc="描述信息"
      :title="item.title"
      :thumb="item.img"
    >
      <template #footer>
        <van-button @click="addItem(item)" type="info" size="mini">＋</van-button>
      </template>
    </van-card>
  </div>
</template>

<script>
import { mapState, mapActions, mapMutations } from 'vuex'
export default {
    created() {
      if (this.classifyList.length === 0) {
        this.init()
      }
    },
    computed: {
      ...mapState({
        classifyList: (state) => state.Car.classifyList
      })
    },
    methods: {
      // 添加商品
      // addItem(item) {

      // },
      ...mapMutations({
        addItem: 'Car/addItem'
      }),
      ...mapActions({
        init: 'Car/init'
      })
    }
}
</script>

<style>
</style>